Data

Palmerpenguins data set is provided by Dr. Allison Kristen Gorman. The goal of palmerpenguins is to provide a great dataset for data exploration & visualization

Single trait distribution

view(penguins)
dim(penguins)
## [1] 344   8
colnames(penguins)
## [1] "species"           "island"            "bill_length_mm"   
## [4] "bill_depth_mm"     "flipper_length_mm" "body_mass_g"      
## [7] "sex"               "year"
ggplot(data = penguins) + 
  geom_violin(mapping = aes(x = bill_length_mm, y = species, color = sex)) 
## Warning: Removed 2 rows containing non-finite values (stat_ydensity).

penguins %>%
  ggplot() +
  geom_density(mapping = aes(x = bill_length_mm, fill=species), alpha=0.5)
## Warning: Removed 2 rows containing non-finite values (stat_density).

Relationship between multiple traits

relationship between body mass and flipper length

ggplot(data = penguins) +
  geom_point(mapping = aes(x = body_mass_g, y = flipper_length_mm, color = species)) + 
  geom_smooth(mapping = aes(x = body_mass_g, y = flipper_length_mm))
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).

Sexual dimorphism

Sexual dimprphism is distinct difference in size or appearance between the sexes of an animal in addition to difference between the sexual organs themselves. what traits are sexually dimprohic in penguins ? (hint: use facet wrap)

ggplot(data = penguins) +
  geom_point(mapping = aes(x = body_mass_g, y = flipper_length_mm, color = species)) + 
  geom_smooth(mapping = aes(x = body_mass_g, y = flipper_length_mm)) + 
  facet_wrap(~species)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).